package com.wesley.arrays;

import java.util.Arrays;

public class ArrayDemo06 {
    public static void main(String[] args) {

        int[] a = {1,3,4,90,10,100,903,490,400};
        System.out.println(a);//[I@1b6d3586
        //打印数组元素 Arrays.toString
        System.out.println(Arrays.toString(a));

        System.out.println("=====");
        printArray(a);

        System.out.println();
        System.out.println("=====");
        //数组进行排序  升序
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));

        System.out.println("=====");
        //数组填充
        Arrays.fill(a,0);
        System.out.println(Arrays.toString(a));
    }

    public static void printArray(int[] a){
        for (int i = 0; i < a.length; i++) {
            if(i == 0){
                System.out.print("[");
            }
            if(i == a.length - 1){
                System.out.print(a[i] + "]");
            }else {
                System.out.print(a[i]+", ");
            }
        }
    }
}
